/**
    Copyright (c) 2010-2011 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

#pragma once

/**    
    @brief  Cuda helper functions.
    @date   2011/02/27
*/

#pragma warning(push)
#pragma warning(disable:4201 4408)
#include <cuda.h>
#include <builtin_types.h>
#include <cuda_runtime_api.h>
#pragma warning(pop)

inline void CudaCheckForErrors( const wchar_t* errorMessage )
{
    cudaError_t err = cudaGetLastError();
    if( cudaSuccess != err) {
       wchar_t errorMsgCuda[ 1024 ];
       wsprintf( errorMsgCuda, L"%s cudaError=%d", errorMessage, err );
        DXUTTrace( __FILE__, __LINE__, E_FAIL,
                         errorMsgCuda, true );
    }
#if 0
#ifdef _DEBUG
    err = cudaThreadSynchronize();
    if( cudaSuccess != err) {
       err = cudaGetLastError();
       wchar_t errorMsgCuda[ 1024 ];
       wsprintf( errorMsgCuda, L"%s cudaError=%d", errorMessage, err );
       DXUTTrace( __FILE__, __LINE__, E_FAIL,
                         errorMsgCuda, true );    }
#endif
#endif
}